import java.util.ArrayList;
import java.util.List;

// 复合节点：文件夹（可包含子组件）
public class Folder implements FileSystemComponent{
    private List<FileSystemComponent> children = new ArrayList<>();
    public void add(FileSystemComponent component) {
        children.add(component);
    }
    @Override
    public int getSize() {
        int total = 0;
        for (FileSystemComponent child : children) {
            total += child.getSize(); // 递归计算子组件大小
        }
        return total;
    }
}
